<template>

  <a-card :bordered="false">
    <!-- 查询区域 -->
    <search :config='searchConfig' @search='search' @getHeight='getHeight'/>
    <div class='page_table'>
      <vxe-grid
        ref='xGrid'
        :border='true'
        :resizable='true'
        :showOverflow='true'
        size='mini'
        :loading='loading'
        :height='pageHeight-seachHeight-90'
        :align='left'
        :columns='columns'
        :data='dataSource'
        :toolbar-config='tableToolbar'
        :checkbox-config='checkboxConfig'
        v-bind='vexConfig'
        @checkbox-change='selectChangeEvent'
        @checkbox-all='selectChangeEvent'
      >
        <template #toolbar_buttons>
          <div class='table-operator'>
            <a-button type="primary" @click="downExportXls('pic_factory_report')">导出</a-button>
          </div>
        </template>

        <template #avatarslot='{ row }'>
          <viewer :images='[row.avatar]'>
            <a-avatar shape='square' size='small' :src='row.avatar' icon='user'/>
          </viewer>
        </template>
        <template #detail='{ row,rowIndex }'>
          <a @click='handleDetail(row)'>{{ row.terminalCode }}</a>
        </template>
        <template #isLeader='{ row }'>
          {{ row.isLeader == 0 ? '是' : '否' }}
        </template>
        <div slot='isActiveStatus' slot-scope='text,recode'>
          {{ text|isActiveStatus }}
        </div>
        <div slot='filterTerminalType' slot-scope='text,recode'>
          {{ text|filterTerminalType }}
        </div>

        <template #action='{ row:record }'>
          <a v-has="'terminal:update'" @click='handleEdit(record)'>编辑</a>
          <a-divider type='vertical'/>
          <a href='javascript:' @click='handleBusiness("门店管理",record)'>日志</a>
        </template>
        <template #imgPathS='{ row }'>
          <viewer :images='row.imgPathS'>
            <a-avatar shape='square' size='small' :src='row.imgPathS' icon='user'/>
          </viewer>
        </template>

        <template #pager>
          <vxe-pager :layouts="['Total', 'PrevJump', 'PrevPage', 'Number', 'NextPage', 'NextJump','Sizes', 'FullJump']"
                     :currentPage.sync='ipagination.current' :page-size.sync='ipagination.pageSize'
                     :total='ipagination.total'
                     :pageSizes='ipagination.pageSizeOptions' @page-change='handlePageChange'>
          </vxe-pager>
        </template>
      </vxe-grid>
    </div>
    <!-- table区域-end -->

    <!-- 表单区域 -->
    <!--<sfaPicFactory-modal ref="modalForm" @ok="modalFormOk"></sfaPicFactory-modal>-->
    <!--<img :src="bigImgSrc"/>-->
  </a-card>
</template>
<script>
import '@/assets/less/TableExpand.less'
// import SfaPicUploadModal from './modules/SfaPicUploadModal'
import {PageListMixin} from '@/mixins/PageListMixin'
import {getAction,deleteAction} from '@/api/manage'

export default {
  name: 'SfaPicUploadList',
  mixins: [PageListMixin],
  components: {
    // ARangePicker,
    // ARow,
    // SfaPicUploadModal
  },
  data() {
    return {
      description: '朋友圈打卡页面',
      //查询区域
      searchConfig: [
        {
          type: 'input',
          name: 'createName',
          placeholder: '打卡人'
        },
        {
          type: 'date',
          name: 'createTime',
          placeholder: '打卡日期'
        },
        {
          type: 'input',
          name: 'updateName',
          placeholder: '审批人'
        },
        {
          type: 'j-select',
          dictCode: 'bpm_Status',
          name: 'bpmStatus',
          placeholder: '审批状态'
        },
        {
          type: 'input',
          name: 'title',
          placeholder: '发布内容'
        },
      ],
      // 表头
      columns: [{
        type: 'checkbox',
        width: 60,
        fixed: 'left'
      },
        {
          title: '打卡人姓名',
          minWidth: 100,
          field: 'createName'
        },
        {
          title: '打卡日期',
          minWidth: 80,
          field: 'createTime'
        },
        {
          title: '打卡时分秒',
          minWidth: 100,
          field: 'createTimeDetail'
        },
        {
          title: '审批人姓名',
          minWidth: 100,
          field: 'updateName'
        },
        {
          title: '审批时间',
          minWidth: 80,
          field: 'updateTime'
        },
        {
          title: '状态',
          minWidth: 80,
          field: 'bpmStatusStr',
        },
        {
          title: '发布类容',
          minWidth: 80,
          field: 'title'
        },
        {
          title: '打卡拍照',
          minWidth: 80,
          field: 'imgPathS',
          slots: { default: 'imgPathS' }
        },
        // {
        //   title: '操作',
        //   field: 'action',
        //   minWidth: 80,
        //   fixed: 'right',
        //   slots: { default: 'action' }
        // }
      ],
      url: {
        list: window._CONFIG['domianSfaURL'] + "/picfactory/findFriendPageList",
        updateApproval: window._CONFIG['domianSfaURL'] + "/picfactory/updateApproval",
        updateApprovalBatch: window._CONFIG['domianSfaURL'] + "/picfactory/updateApprovalBatch",
        startOrStopUrl: window._CONFIG['domianSfaURL']+ "/picfactory/status/startOrStop"
      },
      /* bigImgSrc: "",*/
    }
  },
  methods: {
    updateApproval: function (id) {
      if (!this.url.updateApproval) {
        this.$message.error("请设置url.updateApproval属性!")
        return
      }
      var that = this;
      getAction(that.url.updateApproval, {id: id}).then((res) => {
        if (res.success) {
          that.$message.success(res.message);
          that.loadData();
        } else {
          that.$message.warning(res.message);
        }
      });
    },
    updateApprovalBatch: function () {
      if (!this.url.updateApprovalBatch) {
        this.$message.error("请设置url.updateApprovalBatch属性!")
        return
      }
      if (this.selectedRowKeys.length <= 0) {
        this.$message.warning('请选择一条记录！');

      } else {
        var ids = "";
        for (var a = 0; a < this.selectedRowKeys.length; a++) {
          ids += this.selectedRowKeys[a] + ",";
        }
        var that = this;
        this.$confirm({
          title: "确认通过",
          content: "是否通过选中数据?",
          onOk: function () {
            that.loading = true;
            deleteAction(that.url.updateApprovalBatch, {ids: ids}).then((res) => {
              if (res.success) {
                that.$message.success(res.message);
                that.loadData();
                that.onClearSelected();
              } else {
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.loading = false;
            });
          }
        });
      }
    },
    //   startorstop: function (status) {
    //     if (!this.url.startOrStopUrl) {
    //       this.$message.error("请设置url启用停用!")
    //       return;
    //     }
    //     if (this.selectedRowKeys.length != 1) {
    //       this.$message.warning('请选择一条记录！');
    //       return;
    //     } else {
    //       var id = this.selectedRowKeys[0];
    //       var that = this;
    //       that.loading = true;
    //       getAction(this.url.startOrStopUrl, {id: id, status: status}).then((res) => {
    //         if (res.success) {
    //           that.$message.success(res.message);
    //           that.loadData();
    //         } else {
    //           that.$message.warning(res.message);
    //         }
    //         that.loading = false;
    //       });
    //     }
    //   }
  }
}
</script>

<style scoped>
@import '~@assets/less/common.less';
/*动画*/
.fade-enter-active,
.fade-leave-active {
  transition: all .2s linear;
  transform: translate3D(0, 0, 0);
}

.fade-enter,
.fade-leave-active {
  transform: translate3D(100%, 0, 0);
}

/* bigimg */

.img-view {
  position: relative;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/*遮罩层样式*/
.img-view .img-layer {
  position: fixed;
  z-index: 99998;
  top: 0;
  left: 0;
  background: rgba(0, 0, 0, 0.7);
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/*不限制图片大小，实现居中*/
.img-view .img img {
  position: absolute;
  min-width: 50%;
  max-width: 50%;
  display: block;
  left: 0;
  right: 0;
  margin: auto;
  z-index: 99999;
}
.left {
  position: absolute;
  min-width: 20%;
  max-width: 20%;
  display: block;
  left: 0px;
  margin: auto;
  z-index: 99999;
  top: 50%;
}
.right {
  position: absolute;
  min-width: 20%;
  max-width: 20%;
  display: block;
  right: 0px;top: 50%;
  margin: auto;
  z-index: 99999;
}
.shenpito {
  color: #434e59;
}
.shenpion{
  color: #2eabff;
}
</style>